<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Message {
    /*
     * Security Module Message
     */
    const MSG_SECURITY_INVALID_LOGIN = "Invalid Username or Password";
//
    const MSG_SECURITY_INVALID_USERNAME = "Invalid Username";
//
   
    const MSG_USER_SUCCESS_SAVE="User saved successfully";
    const MSG_USER_ERROR_SAVE="User has been not saved";
    const MSG_USER_SUCCESS_DELETE="User deleted successfully";
    const MSG_USER_ERROR_DELETE="User has been not deleted";
    const MSG_USER_SUCCESS_UPDATE="User updated successfully";
    const MSG_USER_ERROR_UPDATE="User has been not updated";

   const MSG_IMG_UPD= " Image has been updated";
   const MSG_REST_SUCCESS_CNGPASSWORD= " Password has been updated";
   const MSG_SUCCESS_CNGPASSWORD= " Password has been updated";
    const MSG_PDF_ERROR_MSG= " Please Upload PDF File only.";
    const MSG_PDFSIZE_ERROR_MSG= " Please Upload less than 2MB PDF File only.";
   const MSG_IMGSIZE_ERROR_MSG = "Please Upload logo less than 1MB Image only.";
   const MSG_IMGTYPE_ERROR_MSG = "Please Upload logo only in JPG,PNG,GIF and JPEG.";
   const MSG_IMGHEIGHT_WIDTH_ERROR_MSG = "Logo image should have a square aspect ratio (width == height)."; 
   const MSG_OTHERIMAGESIZE_ERROR_MSG = "Please Upload images less than 1 MB.";
   const MSG_OTHERIMGTYPE_ERROR_MSG = "Please Upload Images only in JPG,PNG,GIF and JPEG.";
   
    
    public static function Show($msg, $msgType=MsgType::Suc, $animation=false, $animationType='slideUp') {

        $msgId = time();
        switch ($msgType) {
            case MsgType::Suc : $class = 'sucmsg';
                break;
            case MsgType::Info : $class = 'infomsg';
                break;
            case MsgType::Warn : $class = 'warningmsg';
                break;
            case MsgType::Err : $class = 'errormsg';
                break;
            case MsgType::Val : $class = 'validationmsg';
                break;
            default : $class = 'success';
        }

        $jScript = '';

        if ($animation) {
            !empty($animationType) ? $animationType : 'slideUp';
            $jScript = '<script type="text/javascript">';
            $jScript.='jQuery(document).ready(function($){
                $("#' . $msgId . '").hide();
	 	$("#' . $msgId . '").fadeIn(3000 , function() {';

            if ($animation) {
                $jScript.='setTimeout(function(){$("#' . $msgId . '").' . $animationType . '("slow",function(){$(this).remove()});}, 4000)';
            }
            $jScript.='});
            });';

            $jScript.='</script>';
        }
        $msgOutput = '';
        $msgOutput.='
		<div  id="' . $msgId . '" class="' . $class . ' ui-corner-all ">
                    <div>' . $jScript;

        if (!empty($msg)) {

            if (is_string($msg)) {
                $msg = (array) $msg;
            }

            foreach ($msg as $ms) {
                $msgOutput.='<p>
                                <strong>' . $ms . '</strong>
                             </p>';
            }
        }
        return $msgOutput.='</div>
		</div>';
    }

}
?>
